package com.socialrss.viewlisteners;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import java.util.ArrayList;
import com.socialrss.R;
import com.socialrss.accounts.AccountOwner;
import com.socialrss.accounts.InstagramUser;
import com.socialrss.accounts.dbinterfaces.InstagramConnectionTable;
import com.socialrss.adapters.SocialNetworkAdapter;
import com.socialrss.constants.SocialNetworkNames;
import com.socialrss.instagramkit.InstagramApp;
import com.socialrss.instagramkit.InstagramConstants;
import com.socialrss.instagramkit.InstagramUtils;
import com.socialrss.utils.SocialRssModel;

import android.view.ContextMenu;  


public class ManageSocialNetworks extends BaseActivity{


	//VAR
	ArrayList <String> networkList;
	ArrayList <String> mIcons; 
	ListView networkListView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);		
		setContentView(R.layout.manage_social_networks);
		

		networkList = new ArrayList<String>(4);
		mIcons = new ArrayList <String>(4);
		networkListView = (ListView)findViewById(R.id.msn_networkList);

		networkList.add("Facebook");
		networkList.add("Twitter");
		networkList.add("Google+");
		networkList.add("Instagram");
		
		registerForContextMenu(networkListView);
	    // Instead of using a regular ArrayAdapter to pull Strings from an array,
	    // we will create a custom ArrayAdapter below. This bit of code sets the adapter
	    // of our ListView, lv, to our customer adapter.
		SocialNetworkAdapter adapter = new SocialNetworkAdapter(this, networkList);
	   networkListView.setAdapter(adapter);

	   networkListView.setOnItemClickListener(new OnItemClickListener() {
		   @Override
		   public void onItemClick(AdapterView<?> parent, View view,
				   int position, long id) {
			   Intent intent = null;
			   Bundle bun = new Bundle();
			   
			   if(position == 0) {
				   intent = new Intent(ManageSocialNetworks.this,ConfigureSocialNetwork.class);
				   bun.putString("socialnetwork", SocialNetworkNames.FACEBOOK);
				   intent.putExtras(bun);
			   } else if(position == 1) {
				   intent = new Intent(ManageSocialNetworks.this,ConfigureSocialNetwork.class);
				   bun.putString("socialnetwork", SocialNetworkNames.TWITTER);
				   intent.putExtras(bun);
			   } else if(position == 2) {
				   intent = new Intent(ManageSocialNetworks.this,ConfigureSocialNetwork.class);
				   bun.putString("socialnetwork", SocialNetworkNames.FOURSQUARE);
				   intent.putExtras(bun);
			   } else if(position == 3) {
				   intent = new Intent(ManageSocialNetworks.this,ConfigureSocialNetwork.class);
				   bun.putString("socialnetwork", SocialNetworkNames.INSTAGRAM);
				   intent.putExtras(bun);
			   }
			   startActivity(intent);  
		   }

	   });
	}
		
}	